package com.json.service.impl;

import com.json.dao.UserDAO;
import com.json.dao.impl.UserDAOImpl;
import com.json.entity.User;
import com.json.service.UserService;

public class UserServiceImpl implements UserService {

    //创建dao对象
    private UserDAO userDAO = new UserDAOImpl();

    @Override
    public User login(String username, String password) {
        //通过用户名查用户
        User user = userDAO.selectUserByUsername(username);
        //验证用户是否存在，密码是否正确
        if (user != null){
            if (password.equals(user.getPassword())){
                return user;
            }
        }
        return null;
    }
}
